<?php

use App\Models\OpenShop\SiteLocation\OpenShopSiteLocationModel;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class AlterTableAddSourceToSiteLocations extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('open_shop_site_locations', function (Blueprint $table) {
            $table->unsignedTinyInteger('source')->default(0)->after("id")
                  ->comment(enumToMigrationComment(OpenShopSiteLocationModel::SOURCE_MAP, "选址来源"));
            $table->unsignedInteger('clueRent')->default(0)->after('adSpaceNumber')->comment('线索租金');
            $table->unsignedTinyInteger('clueStatus')->default(0)->after('source')
                  ->comment(enumToMigrationComment(OpenShopSiteLocationModel::CLUE_STATUS_MAP, "房源线索状态"));
            $table->unsignedInteger('putAt')->default(0)->after('orderNo')->comment('上架时间');
            $table->unsignedInteger('bindId')->default(0)->after('orderNo')->comment('选址线索绑定ID');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('open_shop_site_locations', function (Blueprint $table) {
            $table->dropColumn('source');
            $table->dropColumn('clueRent');
            $table->dropColumn('clueStatus');
            $table->dropColumn('putAt');
            $table->dropColumn('bindId');
        });
    }
}
